package com.zkthink.ceres.file.controller;

import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.ceres.file.entity.AttachmentTag;
import com.zkthink.ceres.file.dto.AttachmentTagSaveDTO;
import com.zkthink.ceres.file.dto.AttachmentTagUpdateDTO;
import com.zkthink.ceres.file.dto.AttachmentTagPageDTO;
import com.zkthink.ceres.file.service.AttachmentTagService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 素材标签表
 * </p>
 *
 * @author kellen
 * @date 2020-05-28
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/attachmentTag")
@Api(value = "素材标签", tags = "素材标签")
//@PreAuth(replace = "attachmentTag:")
public class AttachmentTagController extends
    SuperController<AttachmentTagService, Long, AttachmentTag, AttachmentTagPageDTO, AttachmentTagSaveDTO, AttachmentTagUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<AttachmentTag> attachmentTagList = list.stream().map((map) -> {
            AttachmentTag attachmentTag = AttachmentTag.builder().build();
            //TODO 请在这里完成转换
            return attachmentTag;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(attachmentTagList));
    }
}
